from config import URL_PREFIX, STATIC_PATH
from tornado.web import StaticFileHandler

from handlers.annotation_handlers.annotation_handler import GetAnnotationHandler, SaveAllAnnotationsHandler, \
    DeleteAnnotationsHandler, ClassifyAnnotationHandler, UpdateAnnotationHandler, AnnotationDetailHandler
from handlers.data_handlers.data_handler import DataSrarchData, DataNumByProject, DataListByProject, \
    GetDataImageHandler, DataSrarchData_2, DataListByProject2, GetDataImageTrimapHandler
from handlers.health_handlers.health_handler import HealthHandler
from handlers.img_handlers.img_handler import ImgDownloadHandler, DownloadProgressHandler, UpdateResultHandler, \
    ImgUploadHandler, TestDataHandler
from handlers.label_handlers.label_handler import LabelListByProject, AddLabel
from handlers.project_handlers.project_handler import SplitDatasetHandler, ExportDatasetHandler, VersionHandler, \
    DeleteProjectHandler, ListProjectHandler, CreateProjectHandler, EditProjectHandler, UpdateProjectHandler, \
    DeatilProjectHandler, ConformHandler, StateProjectHandler, QuantityHandler
from handlers.rpc_handlers.rpc_handler import CreateCacheHandler, GetCacheHandler
from handlers.user_handlers.user_handler import LoginHandler, RefreshTokenHandler

URLS = [
    (r"/api/statics/(.*)", StaticFileHandler, {"path": STATIC_PATH}),

    # 用户管理
    (URL_PREFIX + r"/login", LoginHandler),  # LDAP登录后携带Token进行本系统登录
    (URL_PREFIX + r"/refresh/token", RefreshTokenHandler),  # 刷新token

    # cache
    (URL_PREFIX + r"/create/cache", CreateCacheHandler),  # create cache
    (URL_PREFIX + r"/get/cache/(?P<cache_id>\d*)", GetCacheHandler),  # get cache
    (URL_PREFIX + r"/health", HealthHandler),

    # 项目管理
    (URL_PREFIX + r"/split/dataset", SplitDatasetHandler),  # 划分数据
    (URL_PREFIX + r"/export/dataset", ExportDatasetHandler),  # 导出数据
    (URL_PREFIX + r"/create/project", CreateProjectHandler),  # 创建项目
    (URL_PREFIX + r"/list/project", ListProjectHandler),  # 查看所有项目  (所有project数据)
    (URL_PREFIX + r"/detail/project", DeatilProjectHandler),  # 查看项目详情  （单条project数据）
    (URL_PREFIX + r"/update/project", UpdateProjectHandler),  # 更新项目
    (URL_PREFIX + r"/edit/project", EditProjectHandler),  # 修改项目
    (URL_PREFIX + r"/delete/project", DeleteProjectHandler),  # 删除项目
    (URL_PREFIX + r"/version", VersionHandler),
    (URL_PREFIX + r"/quantity/project", QuantityHandler),#根据时间查询所有用户标注图片数量
    # 任务管理
    (URL_PREFIX + r"/data/list_by_project", DataListByProject),  # 根据项目查询任务信息
    (URL_PREFIX + r"/data/list_by_project_2", DataListByProject2),  # 根据项目查询任务信息
    (URL_PREFIX + r"/data_id/data", DataSrarchData),  # 根据任务id查询数据  （单条data数据）
    (URL_PREFIX + r"/data_id/data_prev", DataSrarchData_2),  # 根据dataid查询数据(上一页)  （单条data数据）
    (r"/api/datas/(?P<data_id>\d*)/image", GetDataImageHandler),  # 获取原图信息
    (r"/api/datas/(?P<data_id>\d*)/image_trimap", GetDataImageTrimapHandler),  # 获取蒙版图信息
    (URL_PREFIX + r"/data/conform", ConformHandler),  # 标记为不合格
    # # 标签管理
    (URL_PREFIX + r"/label/list_by_project", LabelListByProject),  # 查询项目标签 （查询单个项目的所有label数据）
    (URL_PREFIX + r"/label/add", AddLabel),  # 添加标签
    # 注释管理
    (URL_PREFIX + r"/annotation/get_by_data", GetAnnotationHandler),  # 查询注释信息  （查询单条data的注释信息）
    (URL_PREFIX + r"/annotation/save", SaveAllAnnotationsHandler),  # 保存注释信息
    (URL_PREFIX + r"/annotation/delete", DeleteAnnotationsHandler),  # 删除注释信息
    (URL_PREFIX + r"/annotation/save_classify", ClassifyAnnotationHandler),  # 保存分类注释信息
    (URL_PREFIX + r"/annotation/update", UpdateAnnotationHandler),  # 更新注释信息
    (URL_PREFIX + r"/annotation/detail", AnnotationDetailHandler),  # 返回注释详情  （查询注释和标签信息）
    (URL_PREFIX + r"/state/project", StateProjectHandler)  ,    #项目状态

    #图片下载
    (URL_PREFIX + r"/img/download", ImgDownloadHandler),
    (URL_PREFIX + r"/download/progress", DownloadProgressHandler),
    (URL_PREFIX + r"/update/result", UpdateResultHandler),
    (URL_PREFIX + r"/upload/img", ImgUploadHandler),

    (URL_PREFIX + r"/external/conversations", TestDataHandler),

]